<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="keywords" content="">
		<meta name="description" content="">
		<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1.0, user-scalable=no" />
		<title>上海林业</title>
		<link rel="stylesheet" href="/public/css/bootstrap.min.css" />
		<link rel="stylesheet" href="/public/css/font-awesome.css" />
		<link rel="stylesheet" href="/public/css/public.css" />
	</head>
	<body>

		<div class="containe all-height">
			<div class="all-bd" >
				<img src="../../public/img/bg.jpg" alt="" class="uupic"/>
				<div class="lei-logo">
				    <img src="../../public/img/logo.png" alt="" />
			    </div>
			    <div class="lei-bigtitle">
			    	<img src="../../public/img/titleb.png" alt="" />
			    </div>
			    <div class="lei-smalltitle">
			    	<img src="../../public/img/titlex.png" alt="" />
			    </div>
			    <div class="row margin-bottom-10  vote-list-row">
				    <div class="col-xs-3 col-xs-offset-1 lei-name lei-name-two" >
				    	<span>姓</span><span>名</span>
				    </div>
				    <div class="col-xs-7 lei-input">
				    	<input type="text" name="username" id="username" value="<?=$user['username']?>"/>
				    </div>
			    </div>
			    <div class="row margin-bottom-10 vote-list-row">
				    <div class="col-xs-3 col-xs-offset-1 lei-name lei-name-two" >
				    	<span>性</span>
				    	<span>别</span>
				    </div>
				    <div class="col-xs-7 lei-input">
				    	<select name="selectAge" id="sex">
                           <option value="男" <?php if($user['sex']=='男'){echo 'selected="selected"';}?> >男</option>
                           <option value="女" <?php if($user['sex']=='女'){echo 'selected="selected"';}?> >女</option>
                        </select>
                        <div class="jt">
                        	<span class="fa fa-caret-down"></span>
                        </div>
				    </div>
			    </div>
			    <div class="row  margin-bottom-10 vote-list-row">
				    <div class="col-xs-3 col-xs-offset-1 lei-name lei-name-three" >
				    	<span>手</span><span>机</span><span>号</span>
				    </div>
				    <div class="col-xs-7 lei-input" >
				    	<input type="text" id="phone" value="<?=$user['phone']?>"/>
				    </div>
			    </div>
			    <div class="row margin-bottom-10 vote-list-row">
				    <div class="col-xs-3 col-xs-offset-1 lei-name lei-name-four" >
				    	<span>工</span>
				    	<span>作</span>
				    	<span>单</span>
				    	<span>位</span>
				    </div>
				    <div class="col-xs-3 lei-input margin-bottom-10">
				        <select name="selectAge" id="province" class="selectx">
                           <option value="上海市">上海市</option>
                           <option value="江苏省">江苏省</option>
                        </select>
                        <div class="jt jtx">
                        	<span class="fa fa-caret-down"></span>
                        </div>
                    </div>
                    <div class="col-xs-3 lei-input margin-bottom-10 col-xs-offset-1">
				    	<select name="selectAge" id="city" class="selectx" >
                           <option value="江苏省">上海市</option>
                           <option value="江苏省">江苏省</option>
                       </select>
                       <div class="jt jtx">
                           <span class="fa fa-caret-down"></span>
                       </div>
                    </div>
				    <div class="col-xs-7 lei-input col-xs-offset-4 "  style="position: relative;">
				    	<input type="text" class="lei-address-input" id="company" value="<?=$user['company']?>"/>
				    </div>
			    </div>
			    <div class="row margin-bottom-10 vote-list-row">
				    <div class="col-xs-3 col-xs-offset-1 lei-name lei-name-four"><span>工</span><span>作</span><span>岗</span><span>位</span></div>
				    <div class="col-xs-7 lei-input " >
				    	<select name="selectAge" id="post">
                           <option value="检验检疫" <?php if($user['post']=='检验检疫'){echo 'selected="selected"';}?>>检验检疫</option>
                           <option value="检疫执法" <?php if($user['post']=='检疫执法'){echo 'selected="selected"';}?>>检疫执法</option>
                           <option value="检疫监测" <?php if($user['post']=='检疫监测'){echo 'selected="selected"';}?>>检疫监测</option>
                           <option value="防治技术" <?php if($user['post']=='防治技术'){echo 'selected="selected"';}?>>防治技术</option>
                           <option value="行政管理" <?php if($user['post']=='行政管理'){echo 'selected="selected"';}?>>行政管理</option>
                        </select>
                        <div class="jt">
                           <span class="fa fa-caret-down"></span>
                       </div>
				    </div>
			    </div>
			    <div class="row margin-bottom-10 vote-list-row">
				    <div class="col-xs-3 col-xs-offset-1  lei-name  lei-name-four"><span>个</span><span>人</span><span>爱</span><span>好</span></div>
				    <div class="col-xs-7 lei-input" >
				    	<input type="text" id="hobby" value="<?=$user['hobby']?>"/>
				    </div>
			    </div>
			    <div class="row margin-bottom-10 vote-list-row">
				    <div class="col-xs-3 col-xs-offset-1 lei-name lei-name-four"><span>竞</span><span>赛</span><span>宣</span><span>言</span></div>
				    <div class="col-xs-7 lei-input" >
				    	<input type="text" id="declaration" value="<?=$user['declaration']?>"/>
				    </div>
			    </div>
			    <div class="tj-btn row tk-btn-row vote-list-row">
			    	<div class="col-xs-6 text-center">
			    		<a href="#" class="photo">上传照片</a>
			    	</div>
			    	<div class="col-xs-6 text-center">
			    		<a href="#" class="tj">提交</a>
			    	</div>
			    </div>
			    <div class="lei-organize">
			    	<p>上海市林业总站</p>
			    	<p>上海市林学会</p>
			    </div>
			</div>
		</div>

		<!--test-->
		<div class="tk">
            <div class="image-editor text-center">
                <input type="file" class="cropit-image-input" id="upload">
                <div class="cropit-preview" ></div>
            </div>
			<div class="row tk-btn-row">
			    <div class="col-xs-6 text-center tk-btn">
			    	<a href="#" id="ok">确认</a>
			    </div>
			    <div class="col-xs-6 text-center tk-btn">
			    	<a href="#" id="ok1">取消</a>
			    </div>
			</div>
		</div>
		<input  type="hidden" value='<?=$user['headimgurl']?>' id="headimgurl">

		<script type="text/javascript" src="/public/js/jquery-2.2.3.min.js" ></script>
        <script type="text/javascript" src="/public/js/bootstrap.min.js" ></script>
        <script type="text/javascript" src="/public/js/jquery.cropit.js" ></script>
        <script>
        $(document).ready(function(){
        	var photoHeight = $(".cropit-preview").width();
        	var tkwidth=$(".tk").width();
        	var tkwimg=$(".cropit-preview").width();
        	var tklast=(tkwidth-tkwimg)/2;

        	//alert(bgheight);
        	$(".cropit-preview").height(photoHeight);
        	$(".cropit-preview").css("margin-left",tklast);

        	$(".photo").click(function(){
        		$("#upload").click();
        		$(".tk").show();
        	});
        	$("#ok").click(function(){
        		$(".tk").hide();
        		$(".photo").html("再次上传");
        	});
        	$("#ok1").click(function(){
        		$(".tk").hide();
        	});
        });
        window.onload = function () {
            var bgheight=$(".all-height").height();
            $('.uupic').height(bgheight);
        };
        $(function() {
        $('.image-editor').cropit();

        $('#ok').click(function() {

          // Move cropped image data to hidden input
          var imageData = $('.image-editor').cropit('export');
          $('.hidden-image-data').val(imageData);
          $.post('<?=site_url("welcome/upload")?>',{'img':imageData},function(data){
          		if (data.status=='success') {
          			alert('图片上传成功');
          			// console.log(data.imagePath)
          			$("#headimgurl").val(data.imagePath);
          		}else{
          			alert('上传失败')
          		}
          },'json');
          // window.open(imageData)


          // Prevent the form from actually submitting
          return false;
        });
      });

        $(function(){

        	$.get('<?=site_url("welcome/province")?>',{},function(data){
        		var str = '';
        		for (var i = 0; i < data.length; i++) {
        			str += '<option ';

        			if (<?=($user['province'])?$user['province']:'false';?> == data[i]['id']) {
        				str += 'selected="selected"';
        			}
        			str += 'value="'+data[i]['id']+'">'+data[i]['name']+'</option>';
        		}
        		$('#province').html(str);
        	},'json');

        	$('#province').change(function(){
        		var id = $('#province').val();
        		var url = "<?=site_url('welcome/city')?>/"+id;
        		getCity(url);
        	})

        	function getCity(url){
        		$.get(url,{},function(data){
        			var str = '';
	        		for (var i = 0; i < data.length; i++) {
	        			str += '<option value="'+data[i]['id']+'">'+data[i]['name']+'</option>';
	        		}
	        		$('#city').html(str);
        		},'json');
        	}

        	getCity('<?=site_url("welcome/city")?>/<?=$user["province"]?>');

        	$('.tj').click(function(){
        		var username    = $("#username").val();
				var sex         = $("#sex").val();
				var phone       = $("#phone").val();
				var province    = $("#province").val();
				var city        = $("#city").val();
				var company     = $("#company").val();
				var post        = $("#post").val();
				var hobby       = $("#hobby").val();
				var declaration = $("#declaration").val();
				var headimgurl  = $("#headimgurl").val();

				if (username.trim()==''|| username.length >20) {
					alert('用户名2~20个字符');
					return false;
				}

				reg =  /^1[3|4|5|8|7][0-9]\d{8}$/;
				if(!reg.test(phone)){
					alert('手机号码格式错误，请重新输入');
					return false;
				}

				if (company.trim()==''|| company.length >200) {
					alert('公司2~200个字符');
					return false;
				}

				if (post.trim()==''|| post.length >200) {
					alert('职位2~200个字符');
					return false;
				}

				if (hobby.trim()==''|| hobby.length >200) {
					alert('个人爱好2~200个字符');
					return false;
				}

				if (declaration.trim()==''|| declaration.length >200) {
					alert('竞赛宣言2~200个字符');
					return false;
				}

				if (headimgurl.trim()=='') {
					if (!confirm('您的照片还没上传，确认提交吗？')) {
						return false;
					}
				}

				var requestData = {
					username:username,
					sex:sex,
					phone:phone,
					province:province,
					city:city,
					company:company,
					post:post,
					hobby:hobby,
					declaration:declaration,
					headimgurl:headimgurl
				};

				$.post('<?=site_url("welcome/save_userinfo")?>',requestData,function(data){
					if(data.status==='success'){
						alert('信息提交成功')
					}else{
						alert('信息提交失败'+data.status)
					}
				},'json');
        	})
        })
        </script>
	</body>
</html>


<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
  /*
   * 注意：
   * 1. 所有的JS接口只能在公众号绑定的域名下调用，公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
   * 2. 如果发现在 Android 不能分享自定义内容，请到官网下载最新的包覆盖安装，Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
   * 3. 常见问题及完整 JS-SDK 文档地址：http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
   *
   * 开发中遇到问题详见文档“附录5-常见错误及解决办法”解决，如仍未能解决可通过以下渠道反馈：
   * 邮箱地址：weixin-open@qq.com
   * 邮件主题：【微信JS-SDK反馈】具体问题
   * 邮件内容说明：用简明的语言描述问题所在，并交代清楚遇到该问题的场景，可附上截屏图片，微信团队会尽快处理你的反馈。
   */
   $.getJSON('<?=base_url()?>jssdk/jssdk.php',function(data){

   		wx.config(data);
		wx.ready(function () {
		    // 在这里调用 API
		    wx.onMenuShareTimeline({
				title: '共筑疫情防护墙，同圆生态家园梦。', // 分享标题
				link: window.location.href, // 分享链接
				imgUrl: "<?=base_url()?>public/img/share.jpg", // 分享图标
				success: function () {
					// 用户确认分享后执行的回调函数
				},
				cancel: function () {
					// 用户取消分享后执行的回调函数
				}
			});

			wx.onMenuShareAppMessage({
				title: '共筑疫情防护墙，同圆生态家园梦。', // 分享标题
				desc: '共筑疫情防护墙，同圆生态家园梦。', // 分享描述
				link: window.location.href, // 分享链接
				imgUrl: '<?=base_url()?>public/img/share.jpg', // 分享图标
				type: '', // 分享类型,music、video或link，不填默认为link
				dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
				success: function () {
					// 用户确认分享后执行的回调函数
				},
				cancel: function () {
					// 用户取消分享后执行的回调函数
				}
			});
		});
   });

</script>